Repository navigation
Fixes #38480: Enable MCP sign-in with a public OIDC client - #38701
Conversation
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
Vishnuujain
left a comment
There was a problem hiding this comment.
ran this locally, tests pass. left a couple of comments, the azure one would break existing setups so that one's important
| allowed = attributes.get("issuer") instanceof String scope && isIssuedBy(scope, token); | ||
| } else { | ||
| final String keySetPath = URI.create(publishedKey.keySetUrl()).normalize().getPath(); | ||
| allowed = !templated && !SHARED_ENTRA_KEY_SET.matcher(keySetPath).matches(); |
There was a problem hiding this comment.
I think this breaks azure. common/discovery/keys doesn't have issuer on any key, and that's the url our docs ask people to set. so confidential setups would fail too, not just public. maybe only do this check when the issuer has {tenantid}?
| new URLStreamHandler() { | ||
| @Override | ||
| protected URLConnection openConnection(URL url) throws IOException { | ||
| OutboundUrlPolicy.getInstance().checkForConnect(uri); |
There was a problem hiding this comment.
if the first key url gets blocked (like http://127.0.0.1:8585/...), this throws and the other urls never get tried. could it throw an IOException instead so it's treated like a normal failed download?
| this.sessions = sessions; | ||
| } | ||
|
|
||
| synchronized AuthenticationCodeFlowHandler forMcp(String configuredBaseUrl) { |
There was a problem hiding this comment.
when discovery fails, every sign-in tries it again inside this lock and waits out the timeout. can we remember the failure for a minute or so?
| authority += "/v2.0"; | ||
| } | ||
| final String discovery = authority + DISCOVERY_PATH; | ||
| ValidationHttpUtil.validateUrl(discovery); |
There was a problem hiding this comment.
if someone sets the idp by ip (http://10.0.0.5:8080/...) it gets refused here, and the client just sees "SSO handler not initialized". maybe add a line in the docs that it needs a hostname?
|
@iamkiayun thanks for the PR. Please address the comments above |
|
@harshach @Vishnuujain I addressed all four review comments in On |
|
@iamkiayun thanks, tested again on 25904d6 merged with main, all good. one more thing, docs:
|
Code Review ✅ Approved 🔴 High risk 3 closed / 3 findingsAdds public-client OIDC code exchange and changes MCP ID-token validation, so issuer or key-validation errors could admit an unintended identity or block sign-in. Enables MCP sign-in against public OIDC clients by exchanging authorization codes with S256 PKCE using the configured public client ID and registered callback, with no client secret. Public discovery now refreshes at most once per minute with issuer pinning, and the ADR gained an amendment covering public client registration. The previously open findings on the missing decision record, the uncovered discovery refresh and failure cache, and the early returns in ✅ 3 closed✅ Quality: No decision record covers how the public MCP client is derived
✅ Quality: Public discovery refresh, failure cache and issuer pinning have no record
✅ Quality: forMcp now has an early return and a mid-try return, against the ADR
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
Thanks for the approvals. The backend run has one failing service test: AsyncServiceTest.testShutdownNowClearsMetricsForQueuedDatabaseTasks. It checks cancellation of a queued database task during shutdown. The sign-in tests passed, and this PR doesn’t change the async executor or that test. I tried to rerun the failed job but lack permission. Could a maintainer retry it on 907c768? |
|
@iamkiayun re runned the test, it was flaky earlier |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Not backported to
|
…38965) * Fix MCP sign-in for public OIDC clients (#38480) * Bind public MCP sign-in to its callback and provider configuration * Document public MCP discovery refresh and connection rules * Preserve legacy Azure sign-in and recover from provider discovery failures * Use a single return in the public MCP handler cache * Preserve public OIDC discovery failures after the pac4j upgrade * Document the additional MCP callback in the SSO setup guides * Distinguish the MCP authorization grant from its response type (cherry picked from commit 0ea3fea) Co-authored-by: Kia Yun <kiayun.0218@outlook.com>
Fixes #38480
Public OIDC deployments currently send the MCP client back with
authorization_failedbefore the identity provider sees the login. This change uses the configured public client ID and registered callback to exchange an authorization code with S256 PKCE, without a client secret. It reuses the existing state, identity and consent checks. The provider registration must support server-side code redemption for a public client.The regression signs in through a local identity provider, approves consent and calls
get_user_contextas the expected user. It checks the code exchange, then refreshes and revokes the grant. The focused suites also cover confidential and ordinary public-client sign-in. No live identity-provider tenant was used.Summary by Gitar
This will update automatically on new commits.